home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / modellib / siegelmap_def.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-26  |  1.8 KB  |  96 lines

  1. int siegelmap_init()
  2. {
  3.     title_label = "Siegel Map";
  4.  
  5.     mapping_on = 1;
  6.     inverse_on = 0;
  7.     fderiv_on = 0;
  8.     enable_polar = 0;
  9.     enable_period = 0;
  10.     
  11.     var_dim = 2;
  12.     param_dim = 2;
  13.     func_dim = 2;
  14.  
  15.     (void) malloc_init();
  16.  
  17.     var_label[0] = "x";
  18.     var_label[1] = "y";
  19.     param_label[0] = "rho";
  20.     param_label[1] = "p";
  21.     func_label[0] = "|Rho|^2";
  22.     func_label[1] = "Undefined";
  23.  
  24.     param[0] = 0.618;
  25.     param[1] = 1.;
  26.     var_i[0] = 1.;
  27.     var_i[1] = 0.;
  28.  
  29.     param_min[0]= 0; param_max[0]= 1;
  30.     param_min[1]= 0; param_max[1]= 10;
  31.     var_min[0]= -2; var_max[0]= 2;
  32.     var_min[1]= -2; var_max[1]= 2;
  33.     func_min[0]= 0; func_max[0]= 4;
  34.  
  35.     f_p = siegelmap_f;
  36.     func_p = siegelmap_func;
  37. }
  38. /* Siegel map */
  39. int siegelmap_f(f,index,x,p,t,dim)
  40. int index,dim;
  41. double f[],x[],p[],t;
  42. {
  43.     double xp,yp,xt,yt,theta,rr,alpha,sigma,cx,cy,cossigma,sinsigma;
  44.     if(index ==1) {
  45.         xt = x[0];
  46.         yt= x[1];
  47.         alpha = p[1];
  48.         sigma = p[0];
  49.         sinsigma = sin(twopi*sigma);
  50.         cossigma = cos(twopi*sigma);
  51.         xp = 1-xt;
  52.         yp = -yt;
  53.         if(xp==0){
  54.             if(yp>0)
  55.                 theta = twopi/4;
  56.             else
  57.                 theta = -twopi/4;
  58.         }
  59.         else {
  60.             theta = atan(yp/xp);
  61.             if(xp>0 && yp>=0)
  62.                 theta = theta; 
  63.             else if(xp>0 && yp<0)
  64.                 theta = theta;
  65.             else if(xp<0 && yp>0)
  66.                 theta = twopi/2 + theta;
  67.             else if(xp<0 && yp<0)
  68.                 theta = -(twopi/2 - theta);
  69.         }
  70.         rr = xp*xp + yp*yp;
  71.         rr = exp((alpha+1)/2 * log(rr));
  72.         cx = 1 - rr * cos((alpha+1) * theta);
  73.         cy = -rr * sin((alpha+1) * theta);
  74.         cx = cx / (alpha+1);
  75.         cy = cy / (alpha+1);
  76.         f[0] = cossigma * cx - sinsigma * cy; 
  77.         f[1] = sinsigma * cx + cossigma * cy; 
  78.     }
  79.     /* inverse map not defined */
  80. }
  81. int siegelmap_func(f,x,p,t,dim)
  82. double f[],x[],p[],t;
  83. int dim;
  84. {
  85.     int i;
  86.     extern int forward_toggle;
  87.     extern double *v;
  88.     extern int (*f_p)();
  89.     
  90.     (int) f_p(v,forward_toggle,x,p,t,dim);
  91.     f[0] = 0;
  92.     for(i=0;i<dim;i++)
  93.         f[0] += (v[i]-x[i])*(v[i]-x[i]);
  94.     
  95. }
  96.